<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基本列表</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div id="root">
        <!-- 遍历数组 -->
        <h1>遍历数组</h1>
        <ul>
            <li v-for="(a, b, c) in persons" :key="b">
                {{a.id}}-{{a.name}}-{{a.age}}
            </li>
        </ul>

        <!-- 遍历对象 -->
        <h1>遍历对象</h1>
        <ul>
            <li v-for="(a, b, c) in cars" :key="c">
                {{b}} --- {{a}}
            </li>
        </ul>

        <!-- 遍历字符串 -->
        <h1>遍历字符串</h1>
        <li v-for="(a, b) in str" :key="b">
            {{a}} ---  {{b}}
        </li>

        <!-- 遍历指定次数 -->
        <h1>遍历指定次数</h1>
        <li v-for="(a, b) in 5" :key="b">
            {{b}} --- {{a}}
        </li>
    </div>
</body>

<script>
    new Vue({
        el: "#root",
        data: {
            persons: [
                {id: 1, name: "张三", age: 18},
                {id: 2, name: "李四", age: 19},
                {id: 3, name: "王五", age: 20},
            ],
            cars: {
                name: "奔驰",
                price: 1000000,
                color: "red"
            },
            str: "hello"
        }
    })
</script>
</html>